/** \file    mswin/order_queue.h
  * \brief   Typical implementation of order queue for work thread (mswin/work_thread.h).
  * You may subclass it to customize behaviour.
  * \date    2003 - 2004
  * \author  Fedor Chelnokov
  * \version $Header: /home/cscom1r4/cvsroot/cs/include/mswin/order_queue.h,v 1.1 2004/05/02 18:59:40 cscom1r4 Exp $
  */

#ifndef mswin_order_queue_h
#define mswin_order_queue_h

#include <list>
#include <algorithm>

namespace mswin {

template <class O>
class OrderQueue
{
public:
	typedef O OrderType;

protected:
	typedef std::list<O> DequeType;
	DequeType m_Queue;

public:
	bool IsEmpty() const
		{ return m_Queue.empty(); }
	void Clear() 
		{ m_Queue.clear(); } 
	bool Push(const O & o)
		{ m_Queue.push_back(o);
		  return true; }
	void Pop(O & o)
		{ o = m_Queue.front(); 
		  m_Queue.pop_front(); }
	void Remove(const O & o)
		{ DequeType::iterator i = std::find(m_Queue.begin(), m_Queue.end(), o);
		  if (i != m_Queue.end()) m_Queue.erase(i); }
};

} //namespace mswin

#endif //mswin_order_queue_h
